home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc B) / Acorn User China CD-ROM (UK) (Disc B).bin / STUTTGART / FROMUTS / UNIXLIB37B / src_c_strcpy < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-26  |  738 b   |  46 lines

  1. #ifdef __STDC__
  2. static char sccs_id[] = "@(#) strcpy.c 1.1 "__DATE__" HJR";
  3. #else
  4. static char sccs_id[] = "@(#) strcpy.c 1.1 26/9/90 HJR";
  5. #endif
  6.  
  7. /* strcpy.c (c) Copyright 1990 H.Rogers */
  8.  
  9. #ifndef __STDC__
  10. #include "sys/types.h"
  11. #endif
  12. #include <string.h>
  13.  
  14. #ifdef __STDC__
  15. char *strcpy(char *s,register const char *s2)
  16. #else
  17. char *strcpy(s,s2)
  18. char *s;
  19. register const char *s2;
  20. #endif
  21. {
  22. register char *s1 = s;
  23.  
  24. while (*s1++ = *s2++);
  25.  
  26. return(s);
  27. }
  28.  
  29. #ifdef __STDC__
  30. char *strncpy(char *s,register const char *s2,register size_t n)
  31. #else
  32. char *strncpy(s,s2,n)
  33. char *s;
  34. register const char *s2;
  35. register size_t n;
  36. #endif
  37. {
  38. register char *s1 = s;
  39.  
  40. while (n--)
  41.   if (!(*s1++ = *s2++))
  42.     { while (n--) *s1++ = 0; return(s); }
  43.  
  44. return(s);
  45. }
  46.